//
//  File.swift
//  SFQuestion
//
//  Created by sr liu on 2023/7/10.
//

import Foundation

class letCoding {
    //两数之和
    func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
        
        var a = 0, b = 0
        var dic: Dictionary<Int, Int> = Dictionary()
        for i in 0..<nums.count {
            a = i
            let remaind = target - nums[i]
            if let exist = dic[remaind] {
                b = exist
                break
            }
            dic[nums[i]] = i
        }
        return [a,b]
    }
    
    //两数相加
    func addTwoNumbers(_ l1: ListNode?, _ l2: ListNode?) -> ListNode? {
        var listNode: ListNode?
        var overBit = 0
        var p1 = l1
        var p2 = l2
        while p1 != nil && p2 != nil {
            let sum = (p1?.val ?? 0) + (p2?.val ?? 0)
            overBit = sum / 10
            var newVal = sum % 10
            
            var node = ListNode(0)
        }
        
        return listNode
    }
    
}
